package com.honglv.controller.admin;

import com.honglv.pojo.dto.LoginByCodeDTO;
import com.honglv.pojo.dto.LoginByPasswordDTO;
import com.honglv.pojo.result.Result;
import com.honglv.service.AdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: 生
 * @Date: 2024/04/06/20:50
 * @Description:
 */
@RestController
@Slf4j
@Api("管理员")
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;


    /**
     * 管理员通过验证码登录
     * @param loginByCodeDTO
     * @return
     */
    @PostMapping("/loginByCode")
    @ApiOperation("管理员通过验证码登录")
    public Result loginByCode(@RequestBody LoginByCodeDTO loginByCodeDTO){
        return adminService.loginByCode(loginByCodeDTO);
    }

    /**
     * 管理员通过账号密码登录
     * @param loginByPasswordDTO
     * @return
     */
    @PostMapping("/loginByPassword")
    @ApiOperation("管理员通过账号密码登录")
    public Result loginByPassword(@RequestBody LoginByPasswordDTO loginByPasswordDTO){
        return adminService.loginByPassword(loginByPasswordDTO);
    }
}
